﻿using System.ComponentModel.Composition;
using System.Waf.Applications;
using System.Windows.Controls;
using HighLandirect.Applications.ViewModels;
using HighLandirect.Applications.Views;
using HighLandirect.Domain;

namespace HighLandirect.Presentation.Views
{
    [Export(typeof(IProductListView))]
    public partial class ProductListView : UserControl, IProductListView
    {
        public ProductListView()
        {
            InitializeComponent();
        }


        private ProductListViewModel ViewModel { get { return DataContext as ProductListViewModel; } }


        private void ListViewSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            foreach (Product product in e.RemovedItems)
            {
                ViewModel.SelectedProducts.Remove(product);
            }
            foreach (Product product in e.AddedItems)
            {
                ViewModel.SelectedProducts.Add(product);
            }
        }
    }
}
